package com.example.discover.view

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.material.Divider
import androidx.compose.material.Text
import androidx.compose.material.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.*
import com.example.discover.model.Subject
import com.example.featuresdk.theme.DemoTheme

@ExperimentalUnitApi
@Composable
fun DiscoverEntryView(subject: Subject, uiConstraints: LayoutConstraints) {

    val horizontalPadding = 4
    val spacerWidth = 20
    val arrowWidth = 8
    val iconWidthHeight = 30
    val textWidth = uiConstraints.screenWithDp - horizontalPadding - horizontalPadding - iconWidthHeight - spacerWidth - arrowWidth

    Row(horizontalArrangement = Arrangement.Start,
        verticalAlignment = Alignment.Top){

        Spacer(modifier = Modifier.width(horizontalPadding.dp))

        Image(painter = painterResource(subject.logo),
            contentDescription = subject.title,
            modifier = Modifier.width(iconWidthHeight.dp).height(iconWidthHeight.dp))

        Spacer(modifier = Modifier.width(spacerWidth.dp))

        Column {
            Row {
                Text(text = subject.title,color = contentColorFor(DemoTheme.colors.secondary),
                    modifier = Modifier.width(textWidth.dp).height(30.dp),
                    style = DemoTheme.typography.title)

                Text(text = ">",color = Color.LightGray,
                    modifier = Modifier.width(arrowWidth.dp),
                    style = DemoTheme.typography.titleSuffix)
            }

            Divider(modifier = Modifier.height(1.dp).width((textWidth + arrowWidth).dp), Color.LightGray)
        }
        Spacer(modifier = Modifier.width(horizontalPadding.dp))
    }
}